#!/bin/bash
# mysql容器名称
MASTER_DOCKER_NAME=mysql5719_master
# 备份保存路径
MYSQL_BAK_PATH="/opt/module/mysql5719/master"
# 验证参数
FILE_COUNT=$#
if((FILE_COUNT!=2)); then
    echo ">>> 错误：未传递文件参数！"
    echo "  用法：mysql5719_recover_docker.sh password dbname"
    exit;
elif((FILE_COUNT==2));then
    MYSQL_ROOT_PASSWORD=$1
    MYSQL_DB_NAME=$2
    echo "库名：$MYSQL_DB_NAME 库，恢复最后一次备份：$MYSQL_BAK_PATH/$MYSQL_DB_NAME.sql"
fi
docker exec -i $MASTER_DOCKER_NAME mysql -uroot -p$MYSQL_ROOT_PASSWORD $MYSQL_DB_NAME < $MYSQL_BAK_PATH/$MYSQL_DB_NAME.sql